package com.topnav.mc.admin.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topnav.mc.admin.entity.RolePermission;
import com.topnav.mc.admin.entity.bean.RolePermissionBean;
import com.topnav.mc.admin.entity.param.RolePermissionParam;
import com.topnav.mc.base.mc.McMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RolePermissionMapper extends McMapper<RolePermission, RolePermissionBean, RolePermissionParam> {
    String commSql = " SELECT rp.*,p.id AS permissionId,r.`code` AS roleCode,r.`name` AS roleName, p.pm_code AS pmCode, p.pm_name as pmName " +
            " FROM mc_role_permission rp " +
            " LEFT JOIN mc_role r ON rp.role_id = r.id " +
            " LEFT JOIN mc_permission p ON rp.pm_id = p.id " +
            " ${ew.customSqlSegment}";

    @Select(commSql)
    RolePermissionBean selectInfoOne(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    List<RolePermissionBean> selectInfoList(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    Page<RolePermissionBean> selectInfoPage(Page<RolePermissionParam> page, @Param(Constants.WRAPPER) Wrapper queryWrapper);
}
